import requests


class Base:
    def __init__(self):
        self.s = requests.Session()
        # self.token = self.get_token()
        self.token = "eyJhbGciOiJIUzUxMiIsImlhdCI6MTYyMzY2MzUxOCwiZXhwIjoxNjIzNjc0MzE4fQ.eyJpZCI6MiwidG9rZW5faWQiOiJhZG1pbjExMTEyMDIxLTA2LTE0IDE3OjM4OjM4LjY3OTQwMCJ9.C3q8Dtg5AdGhTbln4tlTZ_NEEwTC6JNBvmyyVsvE7-xAmBWi_ngL6QnDhz_gCiEaN0ms5XKMHglmGlSsZIsEcQ"
        # self.s.params = {"access_token": self.token}
        self.s.auth = (self.token, '')

    def get_token(self):
        # post_data = {
        #     "username": "test",
        #     "password": "1111"
        # }
        url = "http://localhost:5000/user/login"
        r = requests.get(url, auth=("admin", "1111"))
        return r.json().get('access_token')
        # r.text

    def send(self, *args, **kwargs):
        return self.s.request(*args, **kwargs)

if __name__ == '__main__':
    base = Base()
    print(base.get_token())